/* eslint-disable */
const rules = {
    username: [
        { required: true, message: '用户名必填' },
        { type: 'string', min: 2, max: 10, message: '用户名长度必须介于2到10位之间' }
    ],
    password: [
        { required: true, message: '密码必填' },
        { type: 'string', min: 2, max: 10, message: '密码长度必须介于2到10位之间' },
        {
            validator(rule, value, callback, source, options) {
                //必须包含大写字母、小写字母和数字
                const pattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]+$/
                if (pattern.test(value)) {
                    callback()
                    return
                } else {
                    callback({ message: '密码必须包含大写字母、小写字母和数字' })
                }
            }
        }
    ]
}
module.exports = rules